<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>
    <button onClick="btn()">按钮</button>
  </div>
</body>

</html>
<script src="./axios.js"></script>
<script>
  let axios = createInstance({
    baseUrl: "http://localhost:3000"
  })
  let cancel = null

  function btn() {
    cancel()
  }

  axios({
    url: "/posts",
    method: "get",
    cancelToken: new CancelToken(function (c) {
      cancel = c
    })
  }).then(({
    data
  }) => {})
</script>